﻿using System;

namespace Narwhunderful.Aphelia.Framework
{

    public class DesignableComponent : DisposableComponent, IDesignableComponent
    {

        public DesignableComponent()
            : base()
        {
        }

        #region IDesignableComponent

        public event EventHandler<EventArgs> DesigningChanged = null;

        bool _isDesigning = false;
        public virtual bool IsDesigning
        {
            get
            {
                return _isDesigning;
            }
            protected set
            {
                _isDesigning = value;
            }
        }


        public virtual void BeginDesigning()
        {
            if (!_isDesigning)
            {
                _isDesigning = true;
                OnDesigningChanged();
            }
        }

        public virtual void EndDesigning()
        {
            if (_isDesigning)
            {
                _isDesigning = false;
                OnDesigningChanged();
            }
        }

        protected internal virtual void OnDesigningChanged()
        {
            DesigningChanged.SafeInvoke(this, new EventArgs());
        }

        #endregion

    }

}
